﻿
@*Phải có jquery và jquery.cookie thì code này mới chạy*@
@using Resources

@{
    var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLowerInvariant();
}

@helper selected(string c, string culture)
{
    if (c == culture)
    {
        @:selected="true"
    }
}
<div>
    <span>
        @Localization.ChangeLanguage
    </span>
    <select id="select-language" class="selectpicker">
        <option value="vi-VN" @selected("vi-vn", culture)>
            Tiếng Việt
        </option>
        <option value="en-US" @selected("en-us", culture)>
            English
        </option>

    </select>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('#select-language').bind('change', function (event) {
            $.cookie('_culture', null, { 'path': '/', expires: -1 });
            $.cookie('_culture', $(this).val(), { 'path': '/', expires: 365 });
            location.reload(true);
        });
    });
</script>